﻿using System;
using System.Collections.Generic;
using System.Text;

using stsdev;

namespace WebControlSolutionProviders
{
    class ControlSolutionProvider : ISolutionProvider
    {

        public string Title {
            get { return "WebControl Solution (C# Assembly)"; }
        }

        public bool LaunchSolutionOnComplete
        {
            get { return true; }
        }

        public void InitializeSolution()
        {
            SolutionBuilder.AssemblyDeployment = true;
            SolutionBuilder.SafeControlSettings = true;
            SolutionBuilder.DeploymentTarget = AssemblyDeploymentTarget.GlobalAssemblyCache;
            SolutionBuilder.CasPermissions = false;
        }

        public void AddSolutionItems()
        {
            ControlBuilder.CreateControl("CustomControl1");
            
            string featureActivatedCode = WebControlSolutionProviders.Properties.Resources.ControlWebConfigActivated_cs;
            featureActivatedCode = featureActivatedCode.Replace("@SolutionName", SolutionBuilder.SolutionName);
            featureActivatedCode = featureActivatedCode.Replace("@AssemblyStrongName", SolutionBuilder.FullAssemblyName);

            string featureDeactivatingCode = WebControlSolutionProviders.Properties.Resources.ControlWebConfigDeactivating_cs;
            featureDeactivatingCode = featureDeactivatingCode.Replace("@SolutionName", SolutionBuilder.SolutionName);
            featureDeactivatingCode = featureDeactivatingCode.Replace("@AssemblyStrongName", SolutionBuilder.FullAssemblyName);

            Globals.FeatureActivatedCode.Append(featureActivatedCode);
            Globals.FeatureDeactivatingCode.Append(featureDeactivatingCode);

            //create Feature
            FeatureBuilder.Create(SolutionBuilder.SolutionName, FeatureScopeEnum.Site, true);

        }

    }
}
